home *** CD-ROM | disk | FTP | other *** search
- Path: netnews.cc.wwu.edu!news
- From: Kiet Lam <n9448673@henson.cc.wwu.edu>
- Newsgroups: comp.lang.c++
- Subject: Can't compile template class with g++
- Date: Fri, 22 Mar 1996 16:23:18 -0800
- Organization: Western Washington University
- Message-ID: <31534476.1A120953@henson.cc.wwu.edu>
- NNTP-Posting-Host: gonzo.cc.wwu.edu
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; Linux 1.2.8 i486)
-
- I am having problem compiling the following codes under Linux 1.2.8
- with g++ compiler.
-
- template <class ET> class CTemplate {
- public:
- CTemplate(ET Init);
- void Show(void);
- protected:
- private:
- ET InitValue;
- };
-
- CTemplate::CTemplate(ET Init) { //compiler complains at this line
- InitValue = Init;
- }
-
- void CTemplate::Show(void) { //compiler complains at this line too
- cout << "InitValue = " << InitValue << endl;
- }
-
- When the compiler gets to the constructor and the function, it output
- the messages
-
- parse error before `::'
-
- Am I missing something? I removed the template declaration and
- replaced ET with int and the program compiled. It also compiled when
- I kept the template declaration and moved the function body inside
- the template class specifation.
-